import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";

// 全局样式
import "./styles/index.scss";

// 导入
import ElementUI from "element-ui";
import "element-ui/lib/theme-chalk/index.css";
import "font-awesome/css/font-awesome.min.css";
// 引入 axios
import axios from "axios";

import "./permission"; // permission control

// 全局引入 echarts
import * as echarts from "echarts";
// 将 echarts 挂载到 Vue 上
Vue.prototype.$echarts = echarts;

// element 全局引入
Vue.use(ElementUI);
Vue.config.productionTip = false;

// 将 axios 挂载到 Vue 上
Vue.prototype.$axios = axios;
// 设置接口请求的前缀地址
axios.defaults.baseURL = "/study";
// 全局设置token
axios.interceptors.request.use(function (config) {
  let token = sessionStorage.getItem("token");
  if (token) {
    config.headers["token"] = token;
  }
  return config;
});

new Vue({
  router,
  store,
  render: (h) => h(App),
}).$mount("#app");
